package pri.hillchen.std.concurrent.chapter5;

import java.util.Collection;
import java.util.Iterator;

/**
 * @author:hillchen
 * @DESCRIPTION:
 * @Date: Created in 10:54 2018/2/7 0007.
 */
public abstract class PrintElementRunable<E> extends Thread {
    private Collection<E> collection;
    public PrintElementRunable(Collection<E> collection) {
        this.collection = collection;
    }
    @Override
    public void run() {
        Iterator<E> iterator = collection.iterator();
        while (iterator.hasNext()){
            try {
                Thread.sleep(1500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            E e = iterator.next();
            printlnElement(e);
        }
    }
    abstract void printlnElement(E e);
}
